#ifndef CELL_H
#define CELL_H

template<int n> class Cell;

#include <QDebug>
#include <QList>
#include "abstractnode.h"
#include "node.h"
#include "state.h"
#include "learningdata.h"

struct AV
{
    double V;
    QList<double> cons;
    AV(double _V, QList<double> _cons) : V(_V) , cons(_cons){}
};

template<int n>
class Cell : public AbstractNode
{
private:
    LearningData<n> *data;

    //Indices of the vertices in data
    QList<int> indices;

    //Node containing the cell and id of the cell in the node
    Node *node;
    int id;

    //Others
    int level;
    int nVisits;
    bool doneT;

public:

    //Constructors
    Cell(){}
    Cell(LearningData<n> *a_data, Node *a_node, int a_id, QList<int> list, int a_level):
        data(a_data), indices(list), node(a_node), id(a_id), level(a_level), nVisits(0),doneT(false){}

    //Accessors
    int getLevel();
    int getVisits();
    void incrementVisits();
    void setNode(Node *a_node);

    //Access to AV, given the parameters
    AV getVals(QList<double> list);
    void setVals(double valV,QList<double> valCons ,  QList<double> list);

    //Cell subdivision (deletes the old one)
    void subdivide();

    //Others
    virtual bool isCell();
    State<n> getBarycenter();
    QList<double> getRandomParams();
    virtual void print();
};

#include "cell.hpp"

#endif // CELL_H
